package com.taiji.workOrder.service.impl;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import com.taiji.common.core.domain.entity.SysDictData;
import com.taiji.common.utils.DateUtils;
import com.taiji.common.utils.uuid.IdUtils;
import com.taiji.system.service.impl.SysDictDataServiceImpl;
import com.taiji.workOrder.Utils.ChineseTextToPinyin;
import com.taiji.workOrder.domain.Project;
import com.taiji.workOrder.mapper.ProjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.taiji.workOrder.mapper.WorkOrderMapper;
import com.taiji.workOrder.domain.WorkOrder;
import com.taiji.workOrder.service.IWorkOrderService;

/**
 * 工单明细Service业务层处理
 * 
 * @author taiji
 * @date 2023-02-27
 */
@Service
public class WorkOrderServiceImpl implements IWorkOrderService 
{
    @Autowired
    private WorkOrderMapper workOrderMapper;

    @Autowired
    private ProjectMapper projectMapper;

    @Autowired
    private SysDictDataServiceImpl dictDataService;

    private static final SimpleDateFormat sdf=new SimpleDateFormat("yyyyMMdd");

    /**
     * 查询工单明细
     * 
     * @param id 工单明细主键
     * @return 工单明细
     */
    @Override
    public WorkOrder selectWorkOrderById(String id)
    {
        return workOrderMapper.selectWorkOrderById(id);
    }
    public WorkOrder selectWorkOrderByWorkNumber(String workNumber)
    {
        return workOrderMapper.selectWorkOrderByWorkNumber(workNumber);
    }

    /**
     * 查询工单明细列表
     * 
     * @param workOrder 工单明细
     * @return 工单明细
     */
    @Override
    public List<WorkOrder> selectWorkOrderList(WorkOrder workOrder)
    {
        return workOrderMapper.selectWorkOrderList(workOrder);
    }

    /**
     * 新增工单明细
     * 
     * @param workOrder 工单明细
     * @return 结果
     */
    @Override
    public int insertWorkOrder(WorkOrder workOrder) throws Exception {
        workOrder.setId(IdUtils.fastSimpleUUID());
        return workOrderMapper.insertWorkOrder(workOrder);
    }

    /**
     * 修改工单明细
     * 
     * @param workOrder 工单明细
     * @return 结果
     */
    @Override
    public int updateWorkOrder(WorkOrder workOrder)
    {
        workOrder.setUpdateTime(DateUtils.getNowDate());
        return workOrderMapper.updateWorkOrder(workOrder);
    }

    /**
     * 批量删除工单明细
     * 
     * @param ids 需要删除的工单明细主键
     * @return 结果
     */
    @Override
    public int deleteWorkOrderByIds(String[] ids)
    {
        return workOrderMapper.deleteWorkOrderByIds(ids);
    }

    /**
     * 删除工单明细信息
     * 
     * @param id 工单明细主键
     * @return 结果
     */
    @Override
    public int deleteWorkOrderById(String id)
    {
        return workOrderMapper.deleteWorkOrderById(id);
    }
}
